﻿var theall="quanxianimg|typeimg|outnewsimg|guanneixinwenimg|customimg|faqimg|bookreviewimg|hotlinkimg|libaddrimg|userimg|feedbackimg|imagessimg";
//保存
function SaveSeting()
{
	var i,str="";
	r=theall.split("|");
	for(i=0;i<r.length;i++)
	{
		if(DisplayImg("",r[i],3)==1)
		{
			str+=r[i]+"|";
		}
	}
	if(str!="")
	{
		str="<!!---|"+str+"---!!>";
	}
	SetMyCookie(str);
}
//设置cookie
function SetMyCookie(str)
{
	var expdate=new Date();
	expdate.setTime(expdate.getTime()+(24*60*60*1000*365));
	expirestr=";expires="+expdate.toGMTString();
	var mycookie=str+expirestr;
	document.cookie=mycookie;
}
//全部展开
function DisplayAll(phome)
{
	var i,cstr,str="";
	r=theall.split("|");
	//cookie
	if(phome==3)
	{
		cstr=document.cookie;
		if(cstr!="")
		{
		cr=cstr.split("<!!---");
			if(cr[0]!=cstr)
			{
				crr=cr[1].split("---!!>");
				str=crr[0];
			}
		}
	}
	for(i=0;i<r.length;i++)
	{
		//保存参数
		if(phome==3)
		{
			if(!(str.indexOf("|"+r[i]+"|")==-1))
			{
				DisplayImg("",r[i],1);
			}
			else
			{
				DisplayImg("",r[i],0);
			}
		}
		else
		{
			DisplayImg("",r[i],phome);
		}
	}
}
function DisplayImg(ss,imgname,phome)
{
	var index=imgname.replace("img","");
	var tbody=document.getElementById(index);
	if(tbody==null)
		return;
	
	if(imgname=="quanxianimg")
	{
		img=todisplay(quanxian,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.quanxianimg.src=img;
	}
	else if(imgname=="typeimg")
	{
		img=todisplay(type,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.typeimg.src=img;
	}
	else if(imgname=="outnewsimg")
	{
		img=todisplay(outnews,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.outnewsimg.src=img;
	}
	else if(imgname=="guanneixinwenimg")
	{
		img=todisplay(guanneixinwen,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.guanneixinwenimg.src=img;
	}
	else if(imgname=="libaddrimg")
	{
		img=todisplay(libaddr,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.libaddrimg.src=img;
	}
	else if(imgname=="userimg")
	{
		img=todisplay(user,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.userimg.src=img;
	}
	else if(imgname=="faqimg")
	{
		img=todisplay(faq,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.faqimg.src=img;
	}
	else if(imgname=="customimg")
	{
		img=todisplay(custom,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.customimg.src=img;
	}
	else if(imgname=="hotlinkimg")
	{
		img=todisplay(hotlink,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.hotlinkimg.src=img;
	}
	else if(imgname=="bookreviewimg")
	{
		img=todisplay(bookreview,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.bookreviewimg.src=img;
	}
	else if(imgname=="feedbackimg")
	{
		img=todisplay(feedback,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.feedbackimg.src=img;
	}
	else if(imgname=="imagessimg")
	{
		img=todisplay(imagess,phome);
		if(phome==3)
		{
			return img;
		}
		document.images.imagessimg.src=img;
	}
}
function todisplay(ss,phome)
{
	if(ss!=null)
	{
		var theimg;
		　//全部展开
		 if(phome==1)
		 {
		 	ss.style.display="";
			theimg="jsp/manage/images/noadd.gif";
			return theimg;
		 }
		 //全部折叠
		 else if(phome==2)
		 {
		 	ss.style.display="none";
			theimg="jsp/manage/images/add.gif";
			return theimg;
		 }
		 //cookie
		 else if(phome==3)
		 {
		  if(ss.style.display=="")
		  {
		  	return 1;
		  }
		  else
		  {
		  	return 0;
		  }	
		 }
		 if(ss.style.display=="") 
		 {
		  	ss.style.display="none";
			theimg="jsp/manage/images/add.gif";
		  }
		 else
		 {
		  	ss.style.display="";
			theimg="jsp/manage/images/noadd.gif";
		  }
		  return theimg;
	}
}
function turnit(ss,img)
{
 DisplayImg(ss,img,0);
}
var newWindow = null